package tool;

import java.util.List;

public class PageBean<T> {
    private int PageNo = 1; // 当前页码
    private int PageSize = 15;    // 页面大小，即每页显示记录数
    private int totalCount;          // 记录总数
    private int totalPageCount; // 总页数
    private List<T> newsList;         // 每页新闻集合

    public PageBean(int pageNo, int pageSize, int totalCount, List<T> newsList) {
        PageNo = pageNo;
        PageSize = pageSize;
        this.setTotalCount(totalCount);
        this.newsList = newsList;

    }

    public int getPageNo() {
        return PageNo;
    }

    public void setPageNo(int pageNo) {
        this.PageNo = pageNo;
    }

    public int getPageSize() {
        return PageSize;
    }

    public void setPageSize(int pageSize) {
        this.PageSize = pageSize;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        if (totalCount>0){
            this.totalCount = totalCount;
            this.totalPageCount=(this.totalCount % PageSize == 0) ?
                    (this.totalCount / PageSize) :
                    ((this.totalCount / PageSize) + 1);
        }

    }

    public int getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public List<T> getNewsList() {
        return newsList;
    }

    public void setNewsList(List<T> newsList) {
        this.newsList = newsList;
    }
}
